#include <iostream>
#include <algorithm>

using namespace std;

int p1, p2, p3, n;
string s, ans;

bool isdig(char ch)
{
	return ch >= '0' && ch <= '9';
}

bool islet(char ch)
{
	return ch >= 'a' && ch <= 'z';
}

void add(char left, char right)
{
	string t;
	for(char ch = left + 1; ch < right; ch++)
	{
		char tmp = ch;
		if(p1 == 2 && islet(ch)) tmp -= 32;
		else if(p1 == 3) tmp = '*';
		
		for(int i = 0; i < p2; i++) t += tmp;
	}
	
	if(p3 == 2) reverse(t.begin(), t.end());
	
	ans += t;
}

int main()
{ 
	cin >> p1 >> p2 >> p3 >> s;
	n = s.size();
	
	for(int i = 0; i < n; i++)
	{
		if(s[i] != '-' || i == 0 || i == n - 1) ans += s[i];
		else
		{
			char left = s[i - 1], right = s[i + 1]; 
			if(isdig(left) && isdig(right) && left < right
			|| islet(left) && islet(right) && left < right)
			{
				add(left, right);
			}
			else
			{
				ans += s[i];
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}
